import Vue from "vue"
import Vuex from "vuex"
Vue.use(Vuex)
const state = {
  notes:[]
}
const mutations = {
  //保存数据
  CHANGE_ACTIVE_LI(state, data) {
    state.notes.push(data)
  },
  //清除数据
  SET_CLEAR_DATA(state,data){
    state.notes = data
  },
  //替换数据
  REPLACE_DATA(state,data){
    state.notes = data
  }
}
const actions = {
  //保存数据
  changeSetting({ commit }, data) {
    commit('CHANGE_ACTIVE_LI', data)
  },
  //清除数据
  clearVuex({ commit }) {
    commit("SET_CLEAR_DATA", []);
  },
  //从本地获取
  replaceState({ commit },data) {
    commit("REPLACE_DATA", data);
  },


}
export default {
  //解决模块名冲突
  namespaced: true,
  state,
  mutations,
  actions
}
